package com.hex.ds.hdtp.core.web.script.test.controller;

import com.hex.ds.hdtp.core.app.common.page.dto.PageDto;
import com.hex.ds.hdtp.core.app.script.test.dto.request.ScriptDataTestListRequestDto;
import com.hex.ds.hdtp.core.app.script.test.service.IScriptDataTestListService;
import com.hex.ds.hdtp.core.web.common.page.PageVo;
import com.hex.ds.hdtp.core.web.common.page.converter.IPageVoAndPageDtoConverter;
import com.hex.ds.hdtp.core.web.script.test.converter.IScriptDataTestListVoConverter;
import com.hex.ds.hdtp.core.web.script.test.vo.query.ScriptDataTestListQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Package: com.hex.ds.hdtp.core.web.test.controller
 * @ClassName ScriptDataTestListController
 * @Description: 带数据测试清单-WEB接口
 * @Author: wz.li
 * @Date 2023/8/1 17:01
 * @Version v2.0.2
 **/
@Slf4j
@RestController
@Api(tags = "04-脚本测试：清单")
@RequestMapping("/api/script/data/test/list")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ScriptDataTestListController {

    private final IScriptDataTestListService scriptDataTestListService;

    private final IScriptDataTestListVoConverter converter;

    private final IPageVoAndPageDtoConverter pageVoAndPageDtoConverter;

    /*
     * @Method: queryListByPage <br>
     * @Param: [scriptDataTestListQueryVo, pageVo] <br>
     * @Return: org.springframework.http.ResponseEntity <br>
     * @Description：分页查询<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/1 17:12 <br>
     * @Version： V2.0.2<br>
     */
    @GetMapping
    @ApiOperation("带数据测试清单-分页查询")
    public ResponseEntity queryListByPage(ScriptDataTestListQueryVo scriptDataTestListQueryVo, PageVo pageVo) {
        log.debug("进入到【ScriptDataTestListController.queryListByPage】方法,参数：{}" + scriptDataTestListQueryVo.toString());
        final PageDto pageDto = pageVoAndPageDtoConverter.toPageDto(pageVo);
        ScriptDataTestListRequestDto requestDto = converter.toScriptDataTestListRequestDto(scriptDataTestListQueryVo);
        return ResponseEntity.ok(scriptDataTestListService.queryListByPage(requestDto, pageDto));
    }

    /*
     * @Method: queryConsanguinityListByPage <br>
     * @Param: [scriptDataTestListQueryVo, pageVo] <br>
     * @Return: org.springframework.http.ResponseEntity <br>
     * @Description：带数据测试清单血缘-分页查询<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/3 17:51 <br>
     * @Version： V2.0.2<br>
     */
    @GetMapping(value = "/queryConsanguinityList")
    @ApiOperation("带数据测试清单血缘-分页查询")
    public ResponseEntity queryConsanguinityListByPage(ScriptDataTestListQueryVo scriptDataTestListQueryVo, PageVo pageVo) {
        log.debug("进入到【ScriptDataTestListController.queryConsanguinityListByPage】方法,参数：{}" + scriptDataTestListQueryVo.toString());
        final PageDto pageDto = pageVoAndPageDtoConverter.toPageDto(pageVo);
        ScriptDataTestListRequestDto requestDto = converter.toScriptDataTestListRequestDto(scriptDataTestListQueryVo);
        return ResponseEntity.ok(scriptDataTestListService.queryConsanguinityListByPage(requestDto, pageDto));
    }

    /*
     * @Method: queryList <br>
     * @Param: [scriptDataTestListQueryVo, pageVo] <br>
     * @Return: org.springframework.http.ResponseEntity <br>
     * @Description：queryList<br>
     * @Author： wz.li<br>
     * @Date： 2023/8/2 16:39 <br>
     * @Version： V2.0.2<br>
     */
    @GetMapping(value = "/queryList")
    @ApiOperation("带数据测试清单-列表查询")
    public ResponseEntity queryList(ScriptDataTestListQueryVo scriptDataTestListQueryVo) {
        log.debug("进入到【ScriptDataTestListController.queryList】方法,参数：{}" + scriptDataTestListQueryVo.toString());
        ScriptDataTestListRequestDto requestDto = converter.toScriptDataTestListRequestDto(scriptDataTestListQueryVo);
        return ResponseEntity.ok(scriptDataTestListService.queryList(requestDto));
    }
}
